1. Field of the Invention
The present invention generally relates to a data storage apparatus, a buffer controller, and a method of storing data, and more particularly, to a data storage apparatus that stores data provided from an exterior system in a recording medium after storing the data in a buffer temporarily, a buffer controller thereof, and a method of storing data used therein.
2. Description of the Related Art
A secondary storage device such as a hard disk drive of a computer usually has a buffer to store data temporarily before the data are stored in a recording medium (write cache function). The write cache function is one of key factors that determine the performance of the secondary storage device.
A hard disk drive will be described below as an example of a data storage apparatus having the write cache function.
FIG. 1 is a schematic drawing showing a hard disk drive, and FIG. 2 is a block diagram showing the hard disk drive.
A hard disk drive 1 is connected to an upper rank system 2, and stores, in response to a write command provided from the upper rank system 2, data transferred from the upper rank system 2 in a magnetic recording disk. The hard disk drive 1 also retrieves, in response to a read command provided from the upper rank system 2, the data stored in the magnetic recording disk, and transfers the data retrieved from the magnetic recording disk to the upper rank system 2. The hard disk drive 1 mainly consists of a circuit board 11 and a disk enclosure 12. The upper rank system is connected to the circuit board 11.
The circuit board 11 includes a hard disk drive controller (HDC) 21, random access memory (RAM) 22, a read channel (RDC) 23, a micro processing unit (MPU) 24, read only memory (ROM) 25, and a servo controller (SVC) 26. On the other hand, the disk enclosure 12 includes a magnetic recording disk 31, a spindle motor 32, a magnetic head 33, a voice coil motor 34, and a head IC 35.
The hard disk drive controller 21 is connected to MPU 24 and ROM 25 through a bus 27, and is controlled by a firmware program stored in ROM 25. The hard disk drive controller 21 is further connected to RAM 22 that is used as a cache memory to temporarily store the data exchanged between the hard disk controller 21 and the upper rank system 2.
According to the write cache function, the hard disk drive controller 21 transfers write data cached in RAM 22 to the read channel 23. The read channel 23 generates a recording signal by modulating the write data, and transfers the recording signal to the head IC 35.
The head IC 35 provides a current corresponding to the recording signal transferred from the read channel 23 to a magnetic head 33. The magnetic head 33 generates a magnetic field corresponding to the current provided by the head IC, and records the recording signal to the magnetic disk 31 by magnetizing the magnetic disk 31.
On the other hand, the magnetic head 33 converts a magnetization of the magnetic disk 31 into a current, and provides the current to the head IC 35. The head IC 35 generates a reproduced signal corresponding to the current, and transfers the reproduced signal to the read channel 23.
The read channel 23 reproduces read data by demodulating the reproduced signal, and transfers read data to the hard disk controller 21. The hard disk controller 21 caches the read data in RAM 22, and transfers the read data to the upper rank system 2.
The read channel 23 obtains a servo signal from the reproduced signal, and provides the servo signal to MPU 24. MPU 24 controls the entire system of the hard disk drive 1 by executing the firmware stored in ROM 25. MPU 24 controls the servo controller 26 using the servo signal provided from the read channel 23. The servo controller 26 controls, in response to the control signal provided from MPU 24, the spindle motor 32 and the voice coil motor 34.
The write cache function performed by the hard disk drive controller 21 will be described next.
The hard disk drive controller 21 caches write data transferred from the upper rank system 2 in RAM 22. Upon finishing the receiving of the write data from the upper rank system 2, the hard disk drive controller 21 informs the upper rank system 2 of the finish. The hard disk drive controller 21 stores the write data cached in RAM 22 in the magnetic recording disk 31 when the cache memory is full. If a plurality of write data is to be stored at the same address of the magnetic recording disk 31, the write data buffered earlier are abandoned and only the write data buffered latest are recorded in the magnetic recording disk 31. If a plurality of write data, which makes a series of continuous data, is received separately using respective write commands, the write data are combined and stored in the magnetic recording disk 31 as one.
The write data are stored in the magnetic recording disk 31 in the order of an address of the write data instead of the order of receipt. The arranging of the write data based on the order to an address is called re-ordering. The reordering reduces useless seek operation of the magnetic head 33, and accordingly, improves the performance of storing the write data in the magnetic recording disk 31 (write performance).
The case in which three computer files each containing more than 64 KB (kilo bytes) are stored in the magnetic recording disk 31 is described next.
FIGS. 3A and 3B are schematic drawings showing the operation of the write processing.
The upper rank system 2 is operated by an operating system (OS) such as Windows, and is set not to store a file containing more than 64 KB, or 128 sectors. If the size of a file is more than 64 KB, but 128 KB or less, the operating system divides the file into two files, one containing data of 64 KB (128 sectors) and the other containing data of less than 64 KB, and issues two write commands. If the size of the file is more than 128 KB (256 sectors), the operating system divides the file into three files or more.
In FIGS. 3A and 3B, the upper rank system 2 has three files to be stored in the magnetic recording disk 31 of the hard disk drive 1. A file Fa contains data of 71 KB to be stored in a memory area starting with the address “5055856” in the magnetic recording disk 31. A file Fb contains data of 72 KB to be stored in a memory area starting with the address “5059952” in the magnetic recording disk 31. A file Fc contains data of 80 KB to be stored in a memory area starting with the address “5051888” in the magnetic recording disk 31.
Because the file Fa contains data of 71 KB, which is greater than 64 KB, the upper rank system 2 issues two write commands C1 and C4 to store the file Fa in the magnetic recording disk 31.
Since the file Fb contains data of 72 KB, which is greater than 64 KB, the upper rank system 2 issues two write commands C2 and C5 to store the file Fb in the magnetic recording disk 31.
Because the file Fc contains data of 80 KB, which is greater than 64 KB, the upper rank system 2 issues two write commands C3 and C6 to store the file Fc in the magnetic recording disk 31.
The command C1 indicates the storing of write data of a designated number of sectors, “128”, in a memory area starting from a designated address “5055856”. The command C2 indicates the storing of write data of a designated number of sectors, “128”, in a memory area starting from a designated address “5059952”. The command C3 indicates the storing of write data of a designated number of sectors, “128”, in a memory area starting from a designated address “5051888”.
The command C4 indicates the storing of write data of a designated number of sectors, “14”, in a memory area starting from a designated address “5055984”. The command C5 indicates the storing of write data of a designated number of sectors, “16”, in a memory area starting from a designated address “5060080”. The command C6 indicates the storing of write data of a designated number of sectors, “32”, in a memory area starting from a designated address “5052016”.
When the cache memory in RAM 22 is full, the hard disk drive controller 21 stores the cached write data in the magnetic recording disk 31 (media write operation).
When the write command C4 is issued, and the cache memory in RAM 22 is full as showed in FIG. 3A, the hard disk drive controller 21 reorders the cached write data and begins to store the cached write data in the magnetic recording disk 31.
The hard disk drive controller 21 reorders the cached write data in the order of an address, and performs the media write operation.
For example, as showed in FIG. 3A, in the first media write operation, the write data of 128 sectors corresponding to the write command C3 are stored in the memory area starting from the address “5051888” of the magnetic recording disk 31.
In the second media write operation, the write data of 142 sectors corresponding to the write commands C1 and C4 are stored in the memory area starting from the address “5055856” of the magnetic recording disk 31. Since the write data corresponding to the write commands C1 and C4 are continuous with each other, the write data are combined into write data containing data of 142 sectors.
In the third media write operation, the write data of 128 sectors corresponding to the write command C2 are stored in the memory area starting from the address “5059952” of the magnetic recording disk 31.
It is appropriate to assume processing times as follows: seek time 3 ms, rotation wait time 4 ms, and media write time 1.28 ms for the first media write operation; seek time 3 ms, rotation wait time 4 ms, and media write time 1.42 ms for the second media write operation; seek time 3 ms, rotation wait time 4 ms, and media write time 1.28 ms for the first media write operation. The total processing time in this case is 24.98 ms.
After all cached write data are stored in the magnetic recording disk 31, the cache memory in RAM 22 is discharged and becomes ready to cache the next write data. Then, the hard disk controller 21 receives the next write commands C5-C9 from the upper rank system 2, and caches the next write data corresponding to the commands C5-C9 in the cache memory in RAM 22.
The hard disk drive controller 21 performs the media write operation in the following order.
As showed in FIG. 3B, in the fourth media write operation, the write data of 16 sectors corresponding to the write command C5 are stored in the memory area starting from the address “5060080” of the magnetic recording disk 31.
In the fifth media write operation, the write data of 32 sectors corresponding to the write command C6 are stored in the memory area starting from the address “5052016” of the magnetic recording disk 31.
Similarly, the write data designated by the write commands C7-C9 are stored in the respective memory areas of the magnetic recording disk 31.
The media write operation corresponding to the write command C5 can be assumed to require a seek time of 1 ms (to be explained below), a rotation wait time of 4 ms, and a media write time of 0.16 ms. The media write operation corresponding to the write command C6 also can be assumed to require a seek time of 3 ms, a rotation wait time of 4 ms, and a media write time of 0.32 ms. Accordingly, the total processing time would be 37.46 ms.
In this case, since the write data are stored in the memory area starting from the address “5059952” in the third media write operation, if the write data designated by the write command C5 are stored in the memory area starting from the address “5060080” before the write data designated by the write command C6, the seek time could be reduced. Therefore, in the above estimation of the total processing time, the seek time corresponding to the write command C5 is set at 1 ms instead of 3 ms.
The write cache function according to the related art, however, does not take it into account that the upper rank system 2 issues a write command file by file.
For example, the total processing time would be 25.46 ms if the following assumption is made: in the first media write operation, the write data of 144 sectors corresponding to the write commands C3 and C6 are stored in the memory area starting from the address “5051888” of the magnetic recording disk 31; in the second media write operation, the write data of 142 sectors corresponding to the write commands C1 and C4 are stored in the memory area starting from the address “5055856” of the magnetic recording disk 31; in the third media write operation, the write data of 160 sectors corresponding to the write commands C2 and C5 are stored in the memory area starting from the address “5059952” of the magnetic recording disk 31.
The following assumption on the processing times is further made: seek time 3 ms, rotation wait time 4 ms, and media write time 1.44 ms for the first media write operation; seek time 3 ms, rotation wait time 4 ms, and media write time 1.42 ms for the second media write operation; seek time 3 ms, rotation wait time 4 ms, and media write time 1.60 ms for the first media write operation. The total processing time in this case is 25.46 ms.
The total processing time, 25.46 ms, in this case is shorter than that of the prior case, 37.46 ms, by 12.14 ms.
This assumption, however, can not be implemented in practice because it does not take the memory capacity of the cache memory in RAM 22 that temporarily stores write data transferred from the upper rank system 2 into account.
In order to reduce the processing time of the media write operations, the hard disk drive controller 21 may be able to receive the write commands C5 and C6 while the write data corresponding to the first write command C3 are being stored in the magnetic recording disk 31, and store the write data corresponding to the write command C6 immediately after the write data corresponding to the write command C3 are stored by extending the media write operation.
The extension of the media write operation is, however, difficult from the technical stand point, and it is not known for sure whether the write command C6 is issued before the hard disk drive controller 21 finishes storing the write data corresponding to the write command C3 in the magnetic recording disk 31. This is also difficult to implement in practice.